package com.tom.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.client.WebSocketClient;
import org.springframework.web.socket.client.WebSocketConnectionManager;
import org.springframework.web.socket.client.standard.StandardWebSocketClient;


@Slf4j
@Configuration
public class WebSocketConfig {

    private String uri;

    @Bean
    public WebSocketHandler webSocketHandler(){
        return new MyWebSocketHandler();
    }

    @Bean
    public WebSocketClient webSocketClient(){

        return new StandardWebSocketClient();
    }

    @Bean
    public WebSocketConnectionManager webSocketConnectionManager(WebSocketHandler webSocketHandler,WebSocketClient webSocketClient){
        WebSocketConnectionManager manager = new WebSocketConnectionManager(webSocketClient, webSocketHandler, "ws://localhost:9113");
        manager.setAutoStartup(true);
        return manager;
    }


}